package com.frogs.ucenter.v1.request;

import javax.servlet.http.HttpServletRequest;

import com.frogs.framework.web.HttpRequestInfo;
import com.frogs.system.util.ApiUrlParamEnum;
import com.frogs.system.web.api.request.Request;
import com.frogs.system.web.exception.RequestIllegalException;

/**
 * 
 *
 * @author lijian
 * @version 2014年4月2日 - 下午8:45:52
 */
public class UserLogoutRequest extends Request {

	/**
	 * 用户id
	 */
	private int userId;
	
	private String ip;
	
	public UserLogoutRequest() {
	}
	
	@Override
	public void parse(HttpServletRequest request) {
		
		HttpRequestInfo requestInfo = new HttpRequestInfo(request);
		
		this.userId = requestInfo.getIntParameter(ApiUrlParamEnum.userId.getParamName(), 0);
		this.ip =requestInfo.getParameter(ApiUrlParamEnum.ip.getParamName(), requestInfo.getUserIp());
		if ("127.0.0.1".equals(ip)) {
			this.ip = requestInfo.getUserIp();
		}
		if (userId < 1) {
			throw new RequestIllegalException("error userId: " + userId);
		}
	}

	public int getUserId() {
		return userId;
	}

	public void setUserId(int userId) {
		this.userId = userId;
	}

	public String getIp() {
		return ip;
	}

	public void setIp(String ip) {
		this.ip = ip;
	}

}
